﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crank.Core
{
    static class AliasPreprocessor
    {
        #region Blackboard Variables

        // Alias, Real
        private static readonly IProperty<IDictionary<string, string>> EntityAliases = Blackboard.Create<IDictionary<string, string>>("EntityAliases");

        #endregion

        public static void Install()
        {
            Preprocessor.AddDirective("alias", Process);
            EntityAliases.Value = new Dictionary<string, string>();
        }

        private static void Process(string[] args)
        {
            if (args.Length < 2)
                throw new Exception("Invalid Alias");
            string realName = args[0];
            for (int i = 1; i < args.Length; i++)
                EntityAliases.Value.Add(args[i], realName);
        }
    }
}
